package aller.board;

import java.util.LinkedList;


public class BoardAnalyzer {

	private BoardImp board;
	private Point current;
	
	public void play(int x, int y, int color) {
		this.current = board.getPoint(x, y);
		assert current.color == Board.BLANK;
		current.color = color;
	}
	
	/**
	 * Identify worms in a board.
	 * @param board
	 */
	public void makeWorms() {
		for(Worm w: current.adjs) {
			if(w.color == current.color) current.adjSelf.add(w);
			else current.adjEnemy.add(w);
		}
		
		if(!current.adjSelf.isEmpty()) {
			Worm w = connect();
			LinkedList<Point> adjs = adjPts(w);
			for(Point p: adjs)
				p.updateWorm(w);
		}
		else {
			for(Worm w: current.adjEnemy)
				current.updateWorm(w);
		}
	}
	
	private Worm connect() {
		return null;
	}
	
	public LinkedList<Point> adjPts(Worm worm) {
		LinkedList<Point> list = new LinkedList<Point>();
		return list;
	}
	
	/**
	 * Analyze life/death of each worm. 
	 * @param board
	 */
	public void tackRead() {
		
	}
	
	public void makeDragons() {
		
	}
	
	
}
